package mr

//
// RPC definitions.
//
// remember to capitalize all names.
//

import "os"
import "strconv"

//
// example to show how to declare the arguments
// and reply for an RPC.
//

type ExampleArgs struct {
	X int
}

type ExampleReply struct {
	Y int
}

type TaskArgs struct {
	WorkerId   int
	WorkerName string
}

type TaskReply struct {
	FileAddress string
	WorkType    int //0:Map state 1:Reduce state
	TaskNumber  int
	Flag        int //it shows that wheather the struct contain
}

type RegistArgs struct {
	WorkerName string //the socket name of worker
}

type RegistReply struct {
	WorkerUuId int
}

type TaskFinishArgs struct {
	WorkType       int
	WorkerId       int
	InputFileName  string
	OutputFileName map[string]bool
}

type TaskFinishReply struct{}

type WorkerExitArgs struct {
	WorkerId int
}

type WorkerExitReply struct{}

type PingArgs struct{}

type PingReply struct {
	WorkerUid                      int
	WorkerName                     string
	WorkerCurrentTaskStage         int
	WorkerCurrentTask              string
	WorkerCurrentTaskProgressStage bool
}

type ShutdownArgs struct{}

type ShutdownReply struct{}

// Add your RPC definitions here.

// Cook up a unique-ish UNIX-domain socket name
// in /var/tmp, for the master.
// Can't use the current directory since
// Athena AFS doesn't support UNIX-domain sockets.
func masterSock() string {
	s := "/var/tmp/824-mr-"
	s += strconv.Itoa(os.Getuid())
	return s
}
